package com.bos.mapper;

import com.bos.data.model.ProjectItemHistoryModel;
import com.bos.data.model.ProjectItemModel;
import com.bos.data.model.ProjectPropertyModel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface Project_itemMapper {
    //1.要插入字段名称到project_property中
    @Insert("insert into project_property(prop,type) values(#{prop},#{type})")
    public int insertProperty(ProjectPropertyModel pro);

    //2.将字段描述插入到project_item中
    @Insert("insert into project_item(proid,proitid,value) values(#{proid},#{proitid},#{value})")
    public int insertItem(ProjectItemModel item);

    //3.根据要插入字段的名称来查询出Project_property中的值
    @Select("select * from Project_property where prop=#{aname}")
    public ProjectPropertyModel findPropertyByProp(String prop);

    @Select("SELECT a.* from project_item  a LEFT JOIN project_property b on a.proid=b.id WHERE a.proid=#{proId}")
    List<ProjectItemModel> findByProid(int proId);

    @Select("SELECT a.* from project_item  a LEFT JOIN project_property b on a.proid=b.id ORDER BY a.proid,a.proitid")
    List<ProjectItemModel> findAll();

    //将字段描述插入到project_item_history中
    @Insert("insert into project_item_history(proid,proitid,value) values(#{proid},#{proitid},#{value})")
    public int insertItemHistory(ProjectItemHistoryModel item);
}